﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

namespace TestEFAbstractEntity1.Migrations
{
    public partial class v1003 : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropColumn(
                name: "OtherMessage",
                table: "WorkNodes");

            migrationBuilder.AlterColumn<string>(
                name: "Discriminator",
                table: "WorkNodes",
                type: "nvarchar(max)",
                nullable: false,
                defaultValue: "",
                oldClrType: typeof(string),
                oldType: "nvarchar(max)",
                oldNullable: true);

            migrationBuilder.CreateTable(
                name: "WorkNodeEvents",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    OtherMessage = table.Column<string>(type: "nvarchar(max)", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_WorkNodeEvents", x => x.Id);
                });

            migrationBuilder.AddForeignKey(
                name: "FK_WorkNodes_WorkNodeEvents_Id",
                table: "WorkNodes",
                column: "Id",
                principalTable: "WorkNodeEvents",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_WorkNodes_WorkNodeEvents_Id",
                table: "WorkNodes");

            migrationBuilder.DropTable(
                name: "WorkNodeEvents");

            migrationBuilder.AlterColumn<string>(
                name: "Discriminator",
                table: "WorkNodes",
                type: "nvarchar(max)",
                nullable: true,
                oldClrType: typeof(string),
                oldType: "nvarchar(max)");

            migrationBuilder.AddColumn<string>(
                name: "OtherMessage",
                table: "WorkNodes",
                type: "nvarchar(max)",
                nullable: true);
        }
    }
}
